package net.gazhi.delonix.rbac.entity;

import java.util.TreeSet;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Transient;

/**
 * 大模块<br>
 * 对应 spring mvc 的控制器 package
 * 
 * @author Jeffrey Lin
 *
 */
@Entity(name = DX_TABLE.dx_module)
public class Module implements Comparable<Module> {

	@Id
	private int id;

	@Column
	private String name;

	@Column(name = "pkg_name")
	private String pkgName;

	/**
	 * 非持久化集合，用于输出计算
	 */
	@Transient
	private TreeSet<Controller> controllers = new TreeSet<Controller>();

	public Module() {
	}

	public Module(int id, String name, String pkgName) {
		this.id = id;
		this.name = name;
		this.pkgName = pkgName;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPkgName() {
		return pkgName;
	}

	/**
	 * 非持久化集合，用于输出计算
	 * 
	 * @return
	 */
	public TreeSet<Controller> getControllers() {
		return controllers;
	}

	@Override
	public int compareTo(Module target) {
		return Integer.compare(this.id, target.id);
	}

}
